<template>
  <el-dialog title="点位负责人变更记录" :visible.sync="show" width="800px" append-to-body @closed="closed">
    <el-table v-loading="listLoading" :data="list" size="small">
      <el-table-column label="变更前负责人" prop="preUserName" show-overflow-tooltip />
      <el-table-column label="变更后负责人" prop="afterUserName" show-overflow-tooltip />
      <el-table-column label="更改人" prop="updatorName" show-overflow-tooltip />
      <el-table-column label="更改时间" prop="updateTime" width="150" />
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  </el-dialog>
</template>
<script>
// 点位负责人变更记录
import { getSpotBuilderChange } from '@/api/cq/patrol'
export default {
  data() {
    return {
      show: false,
      listLoading: false,
      total: 0,
      list: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        patSpotId: '',
        spotBuilderId: ''
      }
    }
  },
  methods: {
    closed() {
      this.total = 0
      this.list = []
      this.queryParams.pageNum = 1
      this.queryParams.pageSize = 10
      this.queryParams.patSpotId = ''
      this.queryParams.spotBuilderId = ''
    },
    open({ patSpotId, spotBuilderId } = {}) {
      if (!patSpotId) return this.msgError('参数错误，点位ID不能为空')

      this.queryParams.patSpotId = patSpotId
      this.queryParams.spotBuilderId = spotBuilderId || ''
      this.show = true
      this.getList()
    },
    async getList() {
      this.listLoading = true
      const res = await getSpotBuilderChange(this.queryParams).catch(() => false)
      this.listLoading = false
      if (res === false) return
      this.list = res.rows || []
      this.total = res.total || 0
    }
  }
}
</script>
